package com.huayue.service;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.huayue.dao.BaseDao;
import com.huayue.util.PageHelper;

/**
 * service模板
 * 
 */
@Service
public abstract class BaseService<T> {
    // 模板模式
    public abstract BaseDao<T> getDao();

    public int insert(T entity) {
        return getDao().insert(entity);
    }

    public int update(T entity) {
        return getDao().update(entity);
    }

    public int delete(T entity) {
        return getDao().delete(entity);
    }

    public List<Map<String, Object>> findAll(Object... obj) {
        return getDao().findAll(obj);
    }

    public List<Map<String, Object>> findPage(PageHelper page, Object... obj) {
        return getDao().findPage(page, obj);
    }

    public Map<String, Object> findOne(T entity) {
        return getDao().findOne(entity);
    }

    public int count(Object... obj) {
        return getDao().count(obj);
    }
}
